from sqlalchemy import ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship

from ...core.models.enums.account import AccountStatus
from .base import TimedBaseModel


class Account(TimedBaseModel):
    __tablename__ = "account"
    __mapper_args__ = {"eager_defaults": True}

    id: Mapped[int] = mapped_column(primary_key=True)
    account_id: Mapped[int]
    status: Mapped[AccountStatus] = mapped_column(server_default="on_moderation")
    user = relationship("User", back_populates="accounts")
    user_id: Mapped[int] = mapped_column(ForeignKey("user.id"))
    deposits = relationship("Deposit", back_populates="account")

    def __repr__(self):
        return f"<Аккаунт №{self.id} {self.account_id}>"

    def __str__(self):
        return self.__repr__()
